package org.yg.c.live.service;

import com.glela.common.util.MD5;
import com.glela.live.models.ChatRoomInfo;
import com.glela.live.models.ChatroomQueryResult;
import com.glela.live.models.ChatroomUserQueryResult;
import com.glela.live.models.CodeSuccessResult;
import com.glela.live.util.RongCloud;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.poi.util.SystemOutLogger;

/**
 * Hello world!
 *
 */
public class App 
{
    /*public static void main(String[] args) {
        System.out.println("2018-01-26 10:10:10".replace(" ","T")+"Z");
        Long currentTime = (System.currentTimeMillis()/1000)+1800;
        String keyString = "/AppName/123-"+currentTime+"-0-0-sEzdtlvYRu";
        String md5Str = DigestUtils.md5Hex(keyString);
        String pushUrl = "rtmp://video-center-bj.alivecdn.com/AppName/123?vhost=live.xiaopulaile.com&auth_key="+currentTime+"-0-0-"+md5Str;
        String pullUrl = "rtmp://live.xiaopulaile.com/AppName/123?auth_key="+currentTime+"-0-0-"+md5Str;
        System.out.println(pushUrl);
        System.out.println(pullUrl);
    }*/
    public static void main(String[] args)throws Exception {
        RongCloud rongCloud = RongCloud.getInstance("n19jmcy59mda9", "6ZGNhD9ZQTzN22");
        System.out.println("************************Chatroom********************");
        // 创建聊天室方法
        ChatRoomInfo[] chatroomCreateChatRoomInfo = {new ChatRoomInfo("chatroomId1","chatroomName1" )};
        CodeSuccessResult chatroomCreateResult = rongCloud.chatroom.create(chatroomCreateChatRoomInfo);
        System.out.println("create:  " + chatroomCreateResult.toString());

        // 加入聊天室方法
        String[] chatroomJoinUserId = {"userId2","userid3","userId4"};
        CodeSuccessResult chatroomJoinResult = rongCloud.chatroom.join(chatroomJoinUserId, "chatroomId1");
        System.out.println("join:  " + chatroomJoinResult.toString());

        // 查询聊天室信息方法
        String[] chatroomQueryChatroomId = {"chatroomId1","chatroomId2","chatroomId3"};
        ChatroomQueryResult chatroomQueryResult = rongCloud.chatroom.query(chatroomQueryChatroomId);
        System.out.println("query:  " + chatroomQueryResult.toString());

        // 查询聊天室内用户方法
        ChatroomUserQueryResult chatroomQueryUserResult = rongCloud.chatroom.queryUser("chatroomId1", "500", "2");
        System.out.println("queryUser:  " + chatroomQueryUserResult.toString());

        // 销毁聊天室方法
        String[] chatroomDestroyChatroomId = {"chatroomId","chatroomId1","chatroomId2"};
        CodeSuccessResult chatroomDestroyResult = rongCloud.chatroom.destroy(chatroomDestroyChatroomId);
        System.out.println("destroy:  " + chatroomDestroyResult.toString());
    }
}
